$(function(){
	var weather = $("._weather1");
	var ws = ["日","一","二","三","四","五","六"];
	var weatherPlayer = function(){
		$.get(
			"weather.do",
//			"weather.json",
			{"t":new Date().getTime()},
			function(data){
				var d = new Date();
				for(var i=0;i<5;i++){
					weather.find("._d"+i).text(("0"+(d.getMonth()+1)).substr(-2)+"/"+("0"+d.getDate()).substr(-2));
					weather.find("._w"+i).text("周"+ws[d.getDay()]);
					d.setDate(d.getDate()+1);
					var v = data.showapi_res_body["f"+(i+1)];
					weather.find("._daily_"+i+"_day_weather").text(v.day_weather);
					weather.find("._daily_"+i+"_day_img").attr("src","imgs/weathercn02/"+Number(v.day_weather_code)+".png");
					weather.find("._daily_"+i+"_day_temphigh").text(v.day_air_temperature);
					weather.find("._daily_"+i+"_night_weather").text(v.night_weather);
					weather.find("._daily_"+i+"_night_img").attr("src","imgs/weathercn02/"+(Number(v.night_weather_code)==0?"-0":Number(v.night_weather_code))+".png");
					weather.find("._daily_"+i+"_night_templow").text(v.night_air_temperature);
				}
				
				weather.find("._temp").text(data.showapi_res_body.now.temperature);
				weather.find("._weather").text(data.showapi_res_body.now.weather);
				weather.find("._temphigh").text(data.showapi_res_body.f1.day_air_temperature);
				weather.find("._templow").text(data.showapi_res_body.f1.night_air_temperature);
				weather.find("._winddirect").text(data.showapi_res_body.now.wind_direction);
				weather.find("._windpower").text(data.showapi_res_body.now.wind_power);
				weather.find("._humidity").text(data.showapi_res_body.now.sd);
				weather.find("._city").text(data.showapi_res_body.cityInfo.c3);
				
				var a = [];
				a.push({name:data.showapi_res_body.now.aqiDetail.area+"地区PM2.5",value:data.showapi_res_body.now.aqiDetail.pm2_5});
				a.push({name:"穿衣指数",value:data.showapi_res_body.f1.index.clothes.title});
				a.push({name:"感冒指数",value:data.showapi_res_body.f1.index.cold.title});
				a.push({name:"舒适指数",value:data.showapi_res_body.f1.index.comfort.title});
				a.push({name:"运动指数",value:data.showapi_res_body.f1.index.sports.title});
				a.push({name:"洗车指数",value:data.showapi_res_body.f1.index.wash_car.title});
				a.push({name:"晾晒指数",value:data.showapi_res_body.f1.index.ls.title});
				
				for(var i=0;i<a.length;i++){
					weather.find("._index_"+i+"_iname").text(a[i].name);
					weather.find("._index_"+i+"_ivalue").text(a[i].value);
				}
			},"json"
		);
	};
	window.setInterval(weatherPlayer,5000);
	weatherPlayer();
});
